<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <base href="${rc.contextPath}/">
    <title>活动信息预览</title>
    <meta name="keywords" content="活动信息预览">
    <meta name="description" content="活动信息预览">

    <#include "/commons/stylesheets.ftl">

    <link href="/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="/layer/skin/layer.css" rel="stylesheet">
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                    <form class="form-horizontal m-t" >
                        <input type="hidden" id="activityId" name="activityId" value="${activity.id}"/>
                        <input type="hidden" id="customerInfos" name="customerInfos" />
                        <input type="hidden" id="searchGender" name="searchGender" />
                        <input type="hidden" id="searchAge" name="searchAge" />
                        <input type="hidden" id="searchMills" name="searchMills" />
                         <div class="form-group">
                            <label class="col-sm-2 control-label">活动企业
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.companyNames!''}</p>
                            </div>
                         </div>

                         <div class="form-group">
                             <label class="col-sm-2 control-label">活动对象
                             </label>
                             <div class="col-sm-10">
                                  <p class="text-left">${activity.searchGender!''}</p>
                                  <p class="text-left">${activity.searchAge!''}</p>
                                  <p class="text-left">${activity.searchMills!''}</p>
                                  <p class="text-left">${activity.searchAgeLimit!''}</p>
                                  <p class="text-left">${activity.searchVehicle!''}</p>
                                  <!--
                                  <p class="text-left">注册时间：${activity.searchStartTime!''} 至 ${activity.searchEndTime!''}</p>
                                  -->
                             </div>
                         </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动内容
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.activityDesc!''}</p>
                            </div>
                        </div>

                        <#if "${activity.limitNumber!''}" != "">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">预发数量
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.limitNumber!''}份</p>
                            </div>
                        </div>
                        </#if>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动名称
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.activityName!''}</p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动时间
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.startTime?string("yyyy-MM-dd HH:mm:ss")}至${activity.endTime?string("yyyy-MM-dd HH:mm:ss")}</p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动地点
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.activityLocation!''}</p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动区域
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${organizationName!''}</p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">发送方式
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">
                                     <#if activity.smsSendType == 1>
                                            立即发送
                                     <#elseif activity.smsSendType == 2>
                                            定时发送
                                     </#if>
                                 </p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">发送时间
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.smsSendTime?string("yyyy-MM-dd HH:mm:ss")}</p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">验证方式
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">
                                    <#if activity.verifyType == 1>
                                         二维码
                                    <#elseif activity.verifyType == 2>
                                         数字码
                                    </#if>
                                 </p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">发送内容
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.smsTemplate!''}</p>
                            </div>
                        </div>
                         <div class="form-group">
                            <label class="col-sm-2 control-label">用户对象
                            </label>

                            <div class="col-sm-10">
                                <input type="hidden" id="activityTargetType"  value="${activity.activityTargetType!''}"/>
                                <label class="checkbox-inline"><a  href="javaScript:showCustomerDiag(${activity.id});">查看绑定用户</a> </label>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <#if "${isSubmit!'0'}"=="1">
                                    <button class="btn btn-primary" type="button" onClick="sendActivity();">确定</button>
                                </#if>
                                <button type="button" class="btn btn-success" onClick="cancelOperation();">取消</button>
                            </div>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 全局js -->
    <#include "/commons/scripts.ftl">

    <!-- jQuery Validation plugin javascript-->
    <script src="/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="/js/plugins/validate/messages_zh.min.js"></script>

    <script src="/layer/layer.js"></script>
    <script src="/js/app.js"></script>
    <script type="text/javascript" src="/bootstrap-table/bootstrap-table.min.js"></script>
    <script type="text/javascript" src="/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <!-- Data picker -->
    <script src="/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script>
        $.validator.setDefaults({
            highlight:function(a){$(a).closest(".form-group").removeClass("has-success").addClass("has-error")},
            success:function(a){a.closest(".form-group").removeClass("has-error").addClass("has-success")},errorElement:"span",
            errorPlacement:function(a,b){if(b.is(":radio")||b.is(":checkbox")){a.appendTo(b.parent().parent().parent())}else{a.appendTo(b.parent())}},errorClass:"help-block m-b-none",validClass:"help-block m-b-none"});

            $().ready(function(){
                $("#commentForm").validate();
                var a="<i class='fa fa-times-circle'></i> ";
                $("#signupForm").validate({
                    rules:{
                        activityName:{required:true,maxlength:20},
                        activityLocation:{required:true,maxlength:50},
                        activityArea:"required",
                        activityUrl:"required",
                        smsSendType:"required",
                        verifyType:"required",
                        smsTemplate:"required",
                        activityType:"required",
                        activityDesc:{required:true,maxlength:100},
                        startTime:"required",
                        endTime:"required"
                    },
                    messages:{
                        activityName:{required:a+"请输入活动名称",maxlength:a+"活动名称限制20字"},
                        activityLocation:{required:a+"请输入活动地点",maxlength:a+"活动名称限制50字"},
                        activityDesc:{required:a+"请输入活动描述",maxlength:a+"活动名称限制100字"}
                    },
                    success : function(label) {
                        label.closest('.form-group').removeClass('has-error');
                        label.remove();
                    },
                    errorPlacement : function(error, element) {
                        element.parent('div').append(error);
                    },
                    submitHandler : function(form) {
                        form.submit();
                    }
                });

                //$('.i-checks').iCheck({
                //    checkboxClass: 'icheckbox_square-green',
               //     radioClass: 'iradio_square-green',
               // });

                $("#dataRange .input-daterange").datepicker({
                    keyboardNavigation:false,
                    forceParse:false,autoclose:true
                });

                $("#dataSelect .input-group.date").datepicker({
                    todayBtn:"linked",
                    keyboardNavigation:false,
                    forceParse:false,
                    calendarWeeks:true,
                    autoclose:true
                });
            });

            function showCustomerDiag(activityId) {
                var activityTargetType =  $("#activityTargetType").val() ;
                openDialog('customerVehicle/getActivityCustomer?id='+ activityId + '&isShowButton=1'+ '&activityTargetType=' + activityTargetType ,'绑定用户列表',800,620);
            }

            function sendActivity(){
                var activityId = $("#activityId").val();
                var handleResponse = function(resp){
                    if (resp.resultCode == "success") {
                        layer.msg('执行成功');
                        var index = parent.layer.getFrameIndex(window.name);
                        //parent.layer.close(index);
                        if(index == undefined) {
                            //关闭当前tab页
                            window.parent.document.getElementById('closeCurrentTab').click();
                            return false;
                        } else {
                            parent.layer.close(index);
                        }

                    } else {
                        layer.msg('执行失败');
                    }
                };
                layer.confirm('确定要执行吗?', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    $.ajax({
                        url:"activity/sendActivity",traditional:true,data:{activityId:activityId},type:'post',success:handleResponse
                    });
                    layer.closeAll();
                });
            }
    </script>


</body>

</html>